﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineAuction.Business;
using OnlineAuction.Entity;

namespace OnlineAuction.Users
{
    public partial class RegisterAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rbtGender.SelectedValue = "1";
            }
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            txtAddress.Text = "";
            txtEmail.Text = "";
            txtFullName.Text = "";
            txtIdentityCard.Text = "";
            txtPassword.Text = "";
            txtPhoneNumber.Text = "";
            txtRePassword.Text = "";
            txtUserName.Text = "";
        }

        protected void btnAddUser_Click(object sender, EventArgs e)
        {
            UserBO bo = new UserBO();
            //create new User entity
            UserDTO u = new UserDTO(txtUserName.Text,txtPassword.Text,txtFullName.Text,
                rbtGender.SelectedValue,txtPhoneNumber.Text,txtAddress.Text,txtEmail.Text,
                txtIdentityCard.Text);
            //Check result add item
            bool flag = bo.AddUsers(u);
            if (flag)
            {
                Response.Redirect("../Home.aspx");
            }
            else
            {
                lbError.Text = "User name is existed";
            }
        }
    }
}